/*
 * @Descripttion:
 * @version: 1.0
 * @Author: 马卓
 * @Date: 2020-08-24 21:16:57
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2020-08-27 20:33:57
 */
import { getExamList, getExamType, postList, getListArr, lookGetListArr } from '../../api/login'
import { Message } from 'view-design'
const state = {
  examlist: [],
  examType: [],
  examListType: [],
  examgetlistType: {}
}

const mutations = {
  listexam(state, payload) {
    state.examlist = payload
  },
  listtype(state, payload) {
    state.examType = payload
  },
  examListone(state, payload) {
    state.examListType = payload
  },
  examgetlist(state, payload) {
    state.examgetlistType = payload
  }
}
const actions = {
  async getList({ commit }) {
    const { data: res } = await getExamList()
    // console.log(res)
    if (res.code !== 1) {
      Message.error(res.msg)
      // this.examlist=res.data
    }
    console.log(res.data)
    commit('listexam', res.data)
    // console.log(this.examlist)
  },
  async ExamType({ commit }) {
    const { data: res } = await getExamType()
    console.log(res)
    if (res.code !== 1) {
      Message.error(res.msg)
    }
    commit('listtype', res.data)
  },
  async postExamList({ dispatch }, payload) {
    const { data: res } = await postList(payload)
    //  console.log(payload)
    console.log(res)
    if (res.code === 1) {
      Message.success(res.msg)
    }
  },
  async getExamListnum({ commit }) {
    const { data: res } = await getListArr()
    console.log(res.exam)
    if (res.code !== 1) {
      Message.error(res.msg)
    }
    commit('examListone', res.exam)
  },
  // async lookListArrs({ dispatch }, payload) {
  //   const { data: res } = await lookListArr(payload)
  //   if (res.code !== 1) {
  //     Message.error(res.msg)
  //   }
  // }
  async getNumList({ commit }) {
    const { data: res } = await lookGetListArr()
    console.log(res.data)
    if (res.code !== 1) {
      Message.error(res.msg)
    }
    commit('examgetlist', res.data)
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}
